home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Magazin/MacEasy 19
/
Mac Magazin and MacEasy Magazine CD - Issue 19.iso
/
Online
/
LineShare 3.3.1
/
LineShare Scripts
/
USR Courier Fax1&ARA&Data
< prev
next >
Wrap
Text File
|
1994-09-13
|
8KB
|
374 lines
! Version 3.0
!
!$ Use this script with USRobotics Courier data/fax modems.
!$ Supports: fax, ARA and regular data incoming calls.
!
!$ Make sure that *Class 1* fax software is installed
!
^2 Speaker On: = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
^3 Speaker Volume: = Enum("Low"="1","Medium"="2","High"="3") "2"
^4 Answer On: = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
^5 Port Speed: = Enum("9600","19200","38400","57600") "19200"
^6 Handshake wires: = Bool("Both"="&D0","CTS only"="&D2") "&D2"
! ------------------------------------------
! Resetting the modem:
! ------------------------------------------
@Hangup
SetTries 2
Flush
HsReset 0,0,0,0,0,0
DtrSet
!
! Try to catch the "OK" answer, use the Escape seq and DTR transitions
! to enter the command mode
!
@Label 1
matchclr
matchstr 1 2 "OK\r\n"
write "ATV1H0&F1\r"
matchread 20
ChrDelay 1
Write "+++"
ChrDelay 0
DtrClear
SBreak
DtrSet
!
DecTries
IfTries 0 1
!
! OSErr -6019 "Modem error - the modem is not responding"
!
exit -6019
@Label 2
write "AT+FCLASS=0\r"
Jsr 100
exit 0
! ------------------------------------------
! Receiving incoming calls
! ------------------------------------------
@ANSWER
!
! Set the modem preferred speed first
!
SerReset Val("^5"),0,8,1
Jsr 80
@Label 10
!
! Set the common options
Jsr 70
!
! Set Fax mode
!
Write "AT+FCLASS=1\r"
Jsr 100
Write "AT+FAA=1\r"
Jsr 100
!
Write "AT&M0&H2&R1&I2S13=1\r"
Jsr 100
!
! Tell the modem to determine the type of the incoming call
! Fetch the tube after ^4 rings
!
Write "ATS0=^4V0\r"
Jsr 110
!
! Everything is ready - let's sit and wait for a call
! We'll wait for 2 minutes, then reinitiate the modem
!
Note "Waiting for a fax/ARA/data call…"
MatchClr
Matchstr 01 13 "2\r"
MatchStr 02 14 "64\r"
MatchStr 03 15 "63\r"
Matchstr 04 57 "1\r"
Matchstr 11 12 "3\r"
Matchstr 12 12 "8\r"
Matchstr 13 12 "7\r"
@Label 11
Matchread 1200
@Label 12
Note "Tuning again…"
Write "ATV1\r"
Jsr 100
Jump 10
@Label 13
Note "Ring…"
jump 11
@Label 14
! SetSpeed 19200
Note "Fax tones detected…"
Jump 11
!
! Data connection established: sitch to verbos and go on-line
!
@Label 15
Note "Data connection…"
!
! Set the communication options:
! • &M0,&B1: Normal connection (for ARA)
! • &H1 &R1: HW out flow control, no in flow control (for ARA, Fax should not use a handshake on receiving)
! • &A1: report connection speed
Write "AT&H1&R1&I0&A1V1&B1O0\r"
MatchClr
MatchStr 01 16 "CONNECT ^$/"
MatchStr 02 16 "CONNECT ^$\r\n"
MatchStr 10 10 "NO CARRIER\r\n"
MatchStr 11 10 "NO ANSWER\r\n"
MatchRead 100
Jump 10
@Label 16
SetVar B "^$"
!
! Data connection has been established (we read "CONNECT")
! Put the "CONNECT" back to the buffer and attach the "Data" subPort
! if it was an incoming call, put the "RING" before the "CONNECT"
!
@Label 20
IfOpen "Data" 21
Jump 30
@Label 21
IfOpen "ARA" 22
Jump 35
@Label 22
Note "Waiting for an ARA frame"
MatchClr
MatchStr 1 23 "^$\r"
MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
MatchStr 3 29 "\01\27\02\29\01\02\01\06"
MatchRead 60
Jump 24
@Label 23
QueueInput "^$\r"
@Label 24
Note "Non-ARA call"
Jump 35
@Label 28
Note "ARA 1.0 call"
Jump 30
@Label 29
Note "ARA 2.0 call"
Jump 30
@Label 30
QueueInput "\r\nCARRIER ^B\r\n"
QueueInput "\r\nRING\r\n"
Attach "ARA" (DTR)
@Label 35
GetSReg C "DATA" 4
QueueInput "\r^CCONNECT ^B\r^C"
ifOriginate 36
QueueInput "\r^CRING\r^C"
@Label 36
Attach "Data" (DTR,Escape,Break)
! ------------------------------------------
! Originating a call through the "ARA" subport
! ------------------------------------------
@ORIGINATE "ARA"
SerReset Val("^5"),0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Set the Data mode:
! • &M0,&B1:Normal connection (no compression, correction - for ARA)
! • &H1,&R1: HW Handshake
! • S7: time-out (90 sec) for long-distance call (if you use them)
! • &A1: report connection rate
!
Write "AT&H1&R1&I0S7=90&A1&M0&B1\r"
Jsr 100
!
! Emit the ARA script commands ("Xnn")
Jsr 60
!
! Prepare to receive all error result codes, dial the number
!
Jsr 90
MatchStr 10 55 "\r\nCONNECT ^$/"
MatchStr 11 55 "\r\nCONNECT ^$\r\n"
MatchRead 1000
Write "\r"
Exit -6019
@Label 55
QueueInput "\r\nCARRIER ^$\r\n"
Attach "ARA" (DTR)
! ------------------------------------------
! Originating a call through the "DATA" subport
! ------------------------------------------
@ORIGINATE "Data"
SerReset Val("^5"),0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Emit the Data commands
Jsr 60
!
! Set the Data mode:
! • &M4,&B1: Auto-reliable
! • &H1,&R1: HW Handshake
! • S7: time-out (90 sec) for long-distance call (if you use them)
! • &A1: ARQ codes
!
Write "AT&M4&B1&H1&R1&I0S7=90\r"
Jsr 100
!
! Prepare to receive all error result codes, dial the number
!
Jsr 90
MatchStr 10 56 "\r\nCONNECT "
MatchRead 1000
Write "\r"
Exit -6019
@Label 56
QueueInput "\r\nCONNECT "
Attach "Data" (DTR,Escape,Break)
! ------------------------------------------
! Originating a call through the "Fax" subPort
! ------------------------------------------
@ORIGINATE "Fax"
!
! Set the "Fax" speed
!
SerReset 19200,0,8,1
Jsr 80
!
! Set the common options
!
Jsr 70
!
! Set the Fax mode
! &H2: Xon/Xoff handshake
!
Write "AT&R1&H2+FCLASS=1\r"
Jsr 100
!
! Now emit all commands that the application has sent to that port,
! except "FCLASS", etc
!
EmitClear "+FCLASS","V","E"
Jsr 60
Write "ATV0\r"
Jsr 110
!
! Prepare to receive all error result codes, dial the number
!
MatchClr
MatchStr 01 57 "1\r"
MatchStr 13 93 "3\r"
MatchStr 14 94 "8\r"
MatchStr 15 92 "7\r"
Write "ATD^1\r"
HsReset *
MatchRead 900
Write "\r"
Exit -6019
!
! Fax connection has been established (we read "FAX")
! Put the "CONNECT" ("1\r") back to the buffer,
! if it was an incoming call, put the "RING" ("2\r") before the "CONNECT"
! Attach the "Fax" subPort
!
@Label 57
QueueInput "1\r"
SetSpeed 19200
ifOriginate 59
!@Label 58
QueueInput "2\r2\r"
@Label 59
Attach "Fax" (Reset(2400),IdleLimit=30)
!
! This section emits all modem commands sent from the client application
! For each set of commands the "OK" answer is awaited
!
@Label 60
EmitStart
@Label 61
EmitCommand 62
Jsr 100
Jump 61
@Label 62
return
!
! This section initiates the modem before ANSWER and ORIGINATEs:
! extended responses + connect at the highest rate + speaker control +
! reset on Dtr drop + DCD valid
! Verbal responses mode, no echo
!
@Label 70
Write "ATX4M^2L^3^6&C1V1E0\r"
Jsr 100
return
!
! This section syncronize the modem after the serial port speed switching
!
@Label 80
ChrDelay 1
Write "AT\r"
ChrDelay 0
Jsr 100
return
!
! Prepare to receive error result codes, send the dialing command and
! set the user's handshake mode
!
@Label 90
MatchClr
MatchStr 2 91 "NO DIALTONE\r\n"
MatchStr 3 92 "BUSY\r\n"
MatchStr 4 93 "NO CARRIER\r\n"
MatchStr 5 94 "NO ANSWER\r\n"
Write "ATD^1\r"
HsReset *
return
@Label 91
exit -6020
@Label 92
exit -6022
@Label 93
exit -6021
@Label 94
exit -6023
!
! Processing the AT command:
! OK -> proceed
! ERROR or TimeOut ->exit -6019
! It can be called AFTER the "Write" command, since LineShare buffers input
!
@Label 100
MatchClr
MatchStr 1 103 "\r\nOK\r\n"
MatchStr 2 102 "\r\nERROR\r\n"
@Label 101
MatchRead 20
@Label 102
Exit -6019
@Label 103
return
@Label 110
MatchClr
MatchStr 1 103 "0\r"
MatchStr 2 102 "4\r"
Jump 101